﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.OleDb;

/// <summary>
/// Summary description for KetNoi
/// </summary>
public class KetNoi
{
#region Khai báo các biến toàn cục
    private OleDbConnection ConObj;
    private OleDbCommand cmd;
#endregion
#region Khởi tạo
    public KetNoi()
	{
        string ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;data source=D:\\DeTai_CuoiKy_ThuongMaiDienTu\\App_Data\\data_dtdd.mdb";//chuoi ket noi
        ConObj = new OleDbConnection(ConStr);
	}
#endregion
#region Các hàm mở - đóng kết nối
    public Boolean Open_Data()
    {
        try
        {
            if (ConObj.State.ToString() == "Close")
                ConObj.Open();
        }
        catch (Exception e)
        {
            return false;
        }
        return true;
    }
    public Boolean Close_Data()
    {
        if (ConObj.State.ToString() == "Open")
            ConObj.Close();
        return true;
    }
#endregion
#region Các hàm lấy dữ liệu (select)
    public DataTable loadDataTable(string SqlStr)
    {
        DataTable dt;
        try
        {           
            Open_Data();
            OleDbDataAdapter adap = new OleDbDataAdapter(SqlStr, ConObj);
            DataSet ds = new DataSet();
            adap.Fill(ds);
            dt = ds.Tables[0];
        }
        catch (Exception e)
        {
            Close_Data();            
            return null;
        }
        Close_Data();
        return dt;
    }
    public DataView loadDataView(string SqlStr)
    {
        DataView dv;
        try
        {
            ConObj.Open();
            OleDbDataAdapter adap = new OleDbDataAdapter(SqlStr, ConObj);
            DataSet ds = new DataSet();
            adap.Fill(ds);
            DataTable dt = ds.Tables[0];
            dv = dt.DefaultView;
        }
        catch (Exception e)
        {
            Close_Data();
            return null;
        }
        Close_Data();
        return dv;
    }
    public OleDbDataReader loadDataReader(string SqlStr)
    {
        OleDbDataReader rs;
        try
        {
            Open_Data();//gọi hàm mở kết nối
            OleDbCommand cmd = new OleDbCommand(SqlStr, ConObj);
            rs = cmd.ExecuteReader();
        }
        catch (Exception e)
        {
            Close_Data();
            return null;
        }
        return rs;
    }
#endregion
#region Các hàm cập nhật dữ liệu
    public Boolean InsertUpdateDelete(string SqlStr)
    {
        try
        {
            Open_Data();
            OleDbCommand cmd =
                new OleDbCommand(SqlStr, ConObj);
            cmd.ExecuteNonQuery();
        }
        catch (Exception e)
        {
            Close_Data();
            return false;
        }
        return true;
    }
 
    public bool ThemTaiKhoanAdmin(string taikhoan,string matkhau,string ten,string diachi,string sdt,string email)//Them Tai Khoan
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "INSERT INTO TaiKhoan (TenTK, MatKhau, Type, HoTen, DiaChi, SoDienThoai,Email) VALUES('" + taikhoan + "','" + matkhau + "','2','" + ten + "','" + diachi + "','" + sdt + "','" + email + "')";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool ThemYKienPhanHoi(string email, string hoten, string diachi, string dienthoai, string noidung)//Them Y Kien Phan Hoi
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "INSERT INTO PhanHoiKhachHang (Email, HoTen, DiaChi, DienThoai, NoiDung) VALUES('" + email + "','" + hoten + "','" + diachi + "','" + dienthoai + "','" + noidung + "')";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }


    public bool ThemDienThoai(string tensp, string gia,string soluong, string kichthuoc, string trongluong, string manhinh, string camera, string thenho, string hinhnho, string thongtin, DateTime ngaydang, string maloai)// Them Dien THoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "INSERT INTO DienThoai (tensp, gia, soluong, kichthuoc, trongluong, manhinh, camera, thenho, hinhanhsmall, thongtin, ngaydang, maloai) VALUES('" + tensp + "','" + gia + "','" + soluong + "','" + kichthuoc + "','" + trongluong + "','" + manhinh + "','" + camera + "','" + thenho + "','" + hinhnho + "','" + thongtin + "','" + ngaydang.Year.ToString() + "/" + ngaydang.Month.ToString() + "/" + ngaydang.Day.ToString() + "','" + maloai + "')";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool ThemNhieuHinhDT(string masp,string hinh1, string hinh2, string hinh3, string hinh4, string hinh5 )// Them Nhieu Hinh DIen Thoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "INSERT INTO HinhAnhChiTiet (masp,Hinh1, Hinh2, Hinh3, Hinh4, Hinh5) VALUES('" + masp + "','" + hinh1 + "','" + hinh2 + "','" + hinh3 + "','" + hinh4 + "','" + hinh5 + "')";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool ThemTinTuc(string TieuDe, string NoiDungTomTat, string NoiDung, DateTime ngaydang, string HinhAnh)// Them Dien THoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "INSERT INTO TinTucDienThoai (TieuDe, NoiDungTomTat,NoiDung, NgayDangTin, HinhAnh) VALUES('" + TieuDe + "','" + NoiDungTomTat + "','" + NoiDung + "','" + ngaydang.Year.ToString() + "/" + ngaydang.Month.ToString() + "/" + ngaydang.Day.ToString() + "','" + HinhAnh + "')";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool ThemLoaiDT(string maloai, string tenloai)
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "INSERT INTO Loai (maloai,tenloai) VALUES('" + maloai + "','" + tenloai + "')";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool ThemLoaiPhuKien(string maloaipk, string tenloaipk)
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "INSERT INTO LoaiPhuKien (MaLoaiPK,TenLoaiPK) VALUES('" + maloaipk + "','" + tenloaipk + "')";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool ThemPhuKien(string tenpk, string gia, string thietbisudung, string chucnang, string xuatxu, string baohanh, DateTime ngaydang, string thongtin, string hinhanh, string maloaipk)// Them Dien THoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "INSERT INTO PhuKienDienThoai (TenPhuKien, Gia, ThietBiSuDung, ChucNang, XuatXu, BaoHanh, NgayNhap, ThongTinChiTiet, HinhAnh, MaLoaiPK) VALUES('" + tenpk + "','" + gia + "','" + thietbisudung + "','" + chucnang + "','" + xuatxu + "','" + baohanh + "','" + ngaydang.Year.ToString() + "/" + ngaydang.Month.ToString() + "/" + ngaydang.Day.ToString() + "','" + thongtin + "','" + hinhanh + "','" + maloaipk+ "')";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public DataTable loadDTTheoMa(string maloai)//Load Loai Dien Thoai
    {
        DataTable dt = new DataTable();
        string SqlStr = "Select * From DienThoai where DienThoai.maloai='" + maloai + "'";
        try
        {
            Open_Data();
            OleDbDataAdapter adap = new OleDbDataAdapter(SqlStr, ConObj);
            DataSet ds = new DataSet();
            adap.Fill(ds);
            dt = ds.Tables[0];
        }
        catch (Exception e)
        {
            Close_Data();
            return null;
        }
        Close_Data();
        return dt;
    }

    public DataTable TimKiemDT(string tensp)// Tim Kiem Dien Thoai theo tu khoa
    {
        DataTable dt = new DataTable();
        string SqlStr = "SELECT * FROM DienThoai where DienThoai.tensp like '%'+'"+tensp+"'+'%'";
        try
        {
            Open_Data();
            OleDbDataAdapter adap = new OleDbDataAdapter(SqlStr, ConObj);
            DataSet ds = new DataSet();
            adap.Fill(ds);
            dt = ds.Tables[0];
        }
        catch (Exception e)
        {
            Close_Data();
            return null;
        }
        Close_Data();
        return dt;
    }

    public DataTable TimDienThoaiTheoGia(string maloai, int giatu, int giaden)// Tim Dien Thoai Theo Gia
    {
        DataTable dt = new DataTable();
        string SqlStr = "select * from DienThoai,Loai where Loai.maloai=DienThoai.maloai and DienThoai.maloai='" + maloai + "' and gia >= " + giatu + " and gia <= " + giaden + "";
        try
        {
            Open_Data();
            OleDbDataAdapter adap = new OleDbDataAdapter(SqlStr, ConObj);
            DataSet ds = new DataSet();
            adap.Fill(ds);
            dt = ds.Tables[0];
        }
        catch (Exception e)
        {
            Close_Data();
            return null;
        }
        Close_Data();
        return dt;
    }

    public DataTable TimPhuKienTheoGia(string maloai, int giatu, int giaden)// Tim Dien Thoai Theo Gia
    {
        DataTable dt = new DataTable();
        string SqlStr = "select * from PhuKienDienThoai,LoaiPhuKien where LoaiPhuKien.MaLoaiPK=PhuKienDienThoai.MaLoaiPK and PhuKienDienThoai.MaLoaiPK='" + maloai + "' and Gia >= " + giatu + " and Gia <= " + giaden + "";
        try
        {
            Open_Data();
            OleDbDataAdapter adap = new OleDbDataAdapter(SqlStr, ConObj);
            DataSet ds = new DataSet();
            adap.Fill(ds);
            dt = ds.Tables[0];
        }
        catch (Exception e)
        {
            Close_Data();
            return null;
        }
        Close_Data();
        return dt;
    }

    public bool ThemNhanXet(string Tieude, string NhanXet,string ThoiGian, string MaKhachHang, string MaSP)// Them Nhan Xet
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "INSERT INTO NhanXet (TieuDe, NhanXet,ThoiGian, KhachHangID, masp) VALUES('" + Tieude + "','" + NhanXet + "','" + ThoiGian + "','" + MaKhachHang + "','" + MaSP + "')";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }


    //public bool XoaSPtheoten(string tensp)//Xoa SP theo ten
    //{
    //    if (ConObj != null)
    //    {
    //        ConObj.Open();
    //        string sql = "delete from DienThoai where tensp='" + tensp + "'";
    //        cmd = new OleDbCommand(sql, ConObj);
    //        cmd.ExecuteNonQuery();
    //    }
    //    return true;
    //}

    public bool XoaLoaiDienThoai(string maloai)//Xoa Loai DT
    {
        if (ConObj != null)
        {
            ConObj.Open();
            string sql = "delete from Loai where maloai='" + maloai + "'"; // '"+masp"' la kieu chuoi , con "masp" la kieu so
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }
    public bool XoaTaiKhoanAdmin(string tentaikhoan)//Xoa TaiKhoan Admin
    {
        if (ConObj != null)
        {
            ConObj.Open();
            string sql = "delete from TaiKhoan where TenTK='" + tentaikhoan + "'"; // '"+masp"' la kieu chuoi , con "masp" la kieu so
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }
    public bool XoaTaiKhoanKhachHang(string makhachhang)//Xoa TaiKhoan Admin
    {
        if (ConObj != null)
        {
            ConObj.Open();
            string sql = "delete from KhachHang where KhachHangID=" + makhachhang + ""; // '"+masp"' la kieu chuoi , con "masp" la kieu so
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool XoaLoaiPhuKien(string maloaipk)//Xoa Loai PhuKien
    {
        if (ConObj != null)
        {
            ConObj.Open();
            string sql = "delete from LoaiPhuKien where MaLoaiPK='" + maloaipk + "'"; // '"+masp"' la kieu chuoi , con "masp" la kieu so
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }


    public bool XoaDienThoai(int masp)//Xoa SP
    {
        if (ConObj != null)
        {
            ConObj.Open();
            string sql = "delete from DienThoai where masp=" + masp + ""; // '"+masp"' la kieu chuoi , con "masp" la kieu so
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }
    public bool XoaDonDatHang(int madondathang)//Xoa DonDatHang
    {
        if (ConObj != null)
        {
            ConObj.Open();
            string sql = "delete from DonDatHang where DonDHID=" + madondathang + ""; // '"+masp"' la kieu chuoi , con "masp" la kieu so
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool XoaPhuKienDT(int maphukien)//Xoa SP
    {
        if (ConObj != null)
        {
            ConObj.Open();
            string sql = "delete from PhuKienDienThoai where MaPhuKien=" + maphukien + ""; // '"+masp"' la kieu chuoi , con "masp" la kieu so
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool XoaTinTuc(int mabantin)//Xoa TinTuc
    {
        if (ConObj != null)
        {
            ConObj.Open();
            string sql = "delete from TinTucDienThoai where MaBanTin=" + mabantin + ""; // '"+masp"' la kieu chuoi , con "masp" la kieu so
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool UpdateLoaiDienThoai(string tenloai, string maloai)// Update LoaiDT
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "UPDATE Loai set tenloai='" + tenloai + "' where maloai='" + maloai + "'";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool UpdateDienThoai(string tensp, string gia,string soluong, string thongtin, string hinhnho, int masp)// Them Dien THoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "UPDATE DienThoai set tensp='" + tensp + "',gia='" + gia + "',soluong='" + soluong + "',thongtin='" + thongtin + "',hinhanhsmall='" + hinhnho + "' where masp=" + masp + "";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool UpdateDienThoaiNeuHinhNull(string tensp, string gia,string soluong,string thongtin, int masp)// Them Dien THoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "UPDATE DienThoai set tensp='" + tensp + "',gia='" + gia + "',soluong='" + soluong + "',thongtin='" + thongtin + "' where masp=" + masp + "";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }


    public bool UpdateTinTuc(string tieude, string noidungtomtat, string noidung, string hinhanh, int mabantin)// Them Dien THoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "UPDATE TinTucDienThoai set TieuDe='" + tieude + "',NoiDungTomTat='" + noidungtomtat + "',NoiDung='" + noidung + "',HinhAnh='" + hinhanh + "' where MaBanTin=" + mabantin + "";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }


    public bool UpdateTinTucNeuHinhNull(string tieude, string noidungtomtat, string noidung, int mabantin)// Them Dien THoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "UPDATE TinTucDienThoai set TieuDe='" + tieude + "',NoiDungTomTat='" + noidungtomtat + "',NoiDung='" + noidung + "' where MaBanTin=" + mabantin + "";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool UpdateLoaiPhuKien(string tenloaipk, string maloaipk)// Update LoaiDT
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "UPDATE LoaiPhuKien set TenLoaiPK='" + tenloaipk + "' where MaLoaiPK='" + maloaipk + "'";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }


    public bool UpdatePhuKienDT(string tenpk, string gia, string baohanh, string thongtin,string hinhanh, int maphukien)// Them Dien THoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "UPDATE PhuKienDienThoai set TenPhuKien='" + tenpk + "',Gia='" + gia + "',BaoHanh='" + baohanh + "',ThongTinChiTiet='" + thongtin + "',HinhAnh='" + hinhanh + "' where MaPhuKien=" + maphukien + "";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool UpdatePhuKienDTNeuHinhNull(string tenpk, string gia, string baohanh, string thongtin, int maphukien)// Them Dien THoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "UPDATE PhuKienDienThoai set TenPhuKien='" + tenpk + "',Gia='" + gia + "',BaoHanh='" + baohanh + "',ThongTinChiTiet='" + thongtin + "' where MaPhuKien=" + maphukien + "";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }


    // Phan Gio Hang
    public bool ThemKhachHang(string hoten,string tinhthanhpho,string quanhuyen, string diachi, string dienthoai, string email)//Them Tai Khoan
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "INSERT INTO KhachHang (HoTen,TinhThanhPho,QuanHuyen, DiaChi,DienThoai, Email) VALUES('" + hoten + "','" + tinhthanhpho + "','" + quanhuyen + "','" + diachi + "','" + dienthoai + "','" + email + "')";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool DangKyThanhVien(string hoten,string matkhau, string tinhthanhpho, string quanhuyen, string diachi, string dienthoai, string email,string ngaydat)//Them Tai Khoan
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "INSERT INTO KhachHang (HoTen,MatKhau,TinhThanhPho,QuanHuyen, DiaChi,DienThoai, Email,NgayDangKy) VALUES('" + hoten + "','" + matkhau + "','" + tinhthanhpho + "','" + quanhuyen + "','" + diachi + "','" + dienthoai + "','" + email + "','" + ngaydat + "')";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }
    public bool ThemDonDatHang(string ngaydat,string hinhthucthanhtoan, string ghichu,string tintrangdh, string makhachhang)//Them Tai Khoan
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "INSERT INTO DonDatHang (NgayDat,HinhThucThanhToan,GhiChu,TinhTrangDonHang,KhachHangID,MaThanhToan) VALUES('" + ngaydat + "','" + hinhthucthanhtoan + "','" + ghichu + "','" + tintrangdh + "','" + makhachhang + "','1')";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }


    public bool ThemChiTietDonDatHang(int iddondathang, int masp, int soluong)//Them Tai Khoan
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "INSERT INTO ChiTietDonHang (DonDHID,masp,SoLuong) VALUES('" + iddondathang + "','" + masp+ "','" + soluong + "')";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool UpdateMatKhauKH(string matkhau, string email)// Update LoaiDT
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "UPDATE KhachHang set MatKhau='" + matkhau + "' where Email='" + email + "'";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }


    public bool UpdateDonDatHang(string diachigiaohang,string ghichu,string tinhtrangdonhang,int mathanhtoan, int madondh)// Them Dien THoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "UPDATE DonDatHang set DiaChiGiaoHang='" + diachigiaohang + "',GhiChu='" + ghichu + "',TinhTrangDonHang='" + tinhtrangdonhang + "',MaThanhToan=" + mathanhtoan + " where DonDHID=" + madondh + "";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool UpdateTaiKhoanAdmin(string taikhoan, string matkhau, string ten, string diachi, string sdt, string email)// Them Dien THoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "UPDATE TaiKhoan set MatKhau='" + matkhau + "',HoTen='" + ten + "',DiaChi='" + diachi + "',SoDienThoai='" + sdt + "',Email='" + email + "' where TenTK='" + taikhoan + "'";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool UpdateTaiKhoanKhachHang(string makhach, string hoten, string matkhau,string diachi, string tinhthanhpho, string dienthoai, string email)// Them Dien THoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "UPDATE KhachHang set HoTen='" + hoten + "',MatKhau='" + matkhau + "',DiaChi='" + diachi + "',TinhThanhPho='" + tinhthanhpho + "',DienThoai='" + dienthoai + "',Email='" + email + "' where KhachHangID=" + makhach + "";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }
    //public bool UpdateTaiKhoanKhachHang(string makhach, string hoten, string matkhau,string tinhthanhpho,string diachi)// Them Dien THoai
    //{
    //    if (ConObj != null)
    //    {
    //        ConObj.Open();

    //        string sql = "UPDATE KhachHang set HoTen='" + hoten + "',MatKhau='" + matkhau + "',TinhThanhPho='" + tinhthanhpho + "' where KhachHangID=" + makhach + "";
    //        cmd = new OleDbCommand(sql, ConObj);
    //        cmd.ExecuteNonQuery();
    //    }
    //    return true;
    //}

    public bool XoaYKienKhach(int ma)//Xoa DonDatHang
    {
        if (ConObj != null)
        {
            ConObj.Open();
            string sql = "delete from PhanHoiKhachHang where IDKhachPhanHoi=" + ma + ""; // '"+masp"' la kieu chuoi , con "masp" la kieu so
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool XoaHinhChiTietDienThoai(int masp)//Xoa DonDatHang
    {
        if (ConObj != null)
        {
            ConObj.Open();
            string sql = "delete from HinhAnhChiTiet where masp=" + masp + ""; // '"+masp"' la kieu chuoi , con "masp" la kieu so
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }

    public bool UpdateYKien(string tinhtrang, int ma)// Them Dien THoai
    {
        if (ConObj != null)
        {
            ConObj.Open();

            string sql = "UPDATE PhanHoiKhachHang set TinhTrang='" + tinhtrang + "' where IDKhachPhanHoi=" + ma + "";
            cmd = new OleDbCommand(sql, ConObj);
            cmd.ExecuteNonQuery();
        }
        return true;
    }
#endregion
}
